
import {constants}  from './index'
import {fromJS} from 'immutable'
import axios from 'axios'

const changeList = (data) => ({
    type:constants.CHANGE_LIST,
    data: fromJS(data),
    totalPage: Math.ceil(data.length / 10)
})
 
export const searchFocus = () => ({
    type:constants.SEARCH_FOUCS
})

export const searchBlur = () => ({
    type:constants.SEARCH_BLUR
})

export const mouseEnter = () => ({
    type: constants.MOUSE_ENTER
})

export const mouseLeave = () => ({
    type: constants.MOUSE_LEAVE
})

export const changePage = (page) => ({
    type: constants.CHANGE_PAGE,
    page
})

export const getList = () => {
    return (dispatch) => {
        // console.log(123)
        axios.get('/api/headerList.json').then((res)=>{ 
            const {data} = res.data 
            for(let i=3;i<=30;i++){
                data.push(i + '高考')
            }
            dispatch(changeList(data))
        }).catch(()=>{
            console.log('error');
        })
    }
}